var total_best_page = 3;
var best_start_like = 10000;
var best_end_like = 50000;



function like(user,id){  
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
     xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
      {     
        likeUpdater(id);
        dislikeUpdater(id);
      }   
    }
     
    xmlhttp.open("GET","likecontent.jsp?u="+user+"&c="+id,true);
    xmlhttp.send();
}

function dislike(user,id){
        if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
     xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        likeUpdater(id);
        dislikeUpdater(id);
        }   
    }

    
    xmlhttp.open("GET","dislikecontent.jsp?u="+user+"&c="+id,true);
    xmlhttp.send();

}

function likeUpdater(id)
{
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
     amlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        amlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    amlhttp.onreadystatechange=function()
    {
    if (amlhttp.readyState==4 && amlhttp.status==200)
       {   
         eval("document.getElementById(\"total_like_"+id+"\").value = "+amlhttp.responseText+" ");
         //alert("sesuatu "+amlhttp.responseText);
       }   
    }
    
    //amlhttp.open("GET","likeupdater.php?c="+id,true);
    amlhttp.open("GET","likeupdater.jsp?c="+id,true);
    amlhttp.send();     
}

function dislikeUpdater(id)
{
        if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
     bmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        bmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    bmlhttp.onreadystatechange=function()
    {
    if (bmlhttp.readyState==4 && bmlhttp.status==200)
        {   
        eval("document.getElementById('total_dislike_"+id+"').value = "+bmlhttp.responseText+" ");
        }   
    }
    
    bmlhttp.open("GET","dislikeupdater.jsp?c="+id,true);
    bmlhttp.send();
    
}

function changePage(pageNumber)
{
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
     xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById('main_content').innerHTML=xmlhttp.responseText;
        }
    }
    
    xmlhttp.open("GET","getContentPage.php?pageNumber="+pageNumber,true);
    xmlhttp.send();

}
